using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class COM_ContactAttributeMap : EntityTypeConfiguration<COM_ContactAttribute>
    {
        public COM_ContactAttributeMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Value)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("COM_ContactAttribute");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Value).HasColumnName("Value");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.Contact).HasColumnName("Contact");

            // Relationships
            this.HasOptional(t => t.COM_Contact)
                .WithMany(t => t.COM_ContactAttribute)
                .HasForeignKey(d => d.Contact);
            this.HasOptional(t => t.COM_ContactAttributeType)
                .WithMany(t => t.COM_ContactAttribute)
                .HasForeignKey(d => d.Type);

        }
    }
}
